import { useEffect, useState } from 'react';
import styles from './RegistrationSuccess.module.css'; // 使用CSS模块导入样式

const RegistrationSuccess = () => {
  const [countdown, setCountdown] = useState(3); // 初始化倒计时为3秒

  useEffect(() => {
    const timer = setInterval(() => {
      setCountdown((prevCountdown) => {
        if (prevCountdown === 1) {
          clearInterval(timer);
          // 在倒计时结束后跳转到指定页面
          window.location.href = '/your-desired-page'; // 替换为您想跳转的页面
        }
        return prevCountdown - 1;
      });
    }, 1000);

    return () => clearInterval(timer);
  }, []);

  return (
    <div className={styles.registrationSuccessContainer}>
      <div className={styles.header}>
      <img src="/1.jpg" alt="智链iLink" className={styles.logo} />
      <h1 style={{color:'white',marginLeft:'-550px'}}>智链iLink</h1>
      </div>
      <div className={styles.content}>
        <img src="/success.png" alt="Success" className={styles.successImage} />
        <h1>注册成功!</h1>
        <p>{countdown}s 后自动跳转...</p>
        <button
          onClick={() => (window.location.href = '/your-desired-page')}
          className={styles.useNowButton}
        >
          立即使用
        </button>
      </div>
    </div>
  );
};

export default RegistrationSuccess;
